package td.pt.event;

import td.domain.TagDef;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.event.shared.HasHandlers;

public class TagAThoughtEvent extends
		GwtEvent<TagAThoughtEvent.TagAThoughtHandler> {

	public static Type<TagAThoughtHandler> TYPE = new Type<TagAThoughtHandler>();
	private TagDef tagDef;
	private HasHandlers source;

	public interface TagAThoughtHandler extends EventHandler {
		void onTagAThought(TagAThoughtEvent event);
	}

	public interface TagAThoughtHasHandlers extends HasHandlers {
		HandlerRegistration addTagAThoughtHandler(TagAThoughtHandler handler);
	}

	public TagAThoughtEvent(TagDef tagDef, HasHandlers source) {
		this.tagDef = tagDef;
	}

	public TagDef getTagDef() {
		return tagDef;
	}

	public HasHandlers getSource() {
		return source;
	}

	@Override
	protected void dispatch(TagAThoughtHandler handler) {
		handler.onTagAThought(this);
	}

	@Override
	public Type<TagAThoughtHandler> getAssociatedType() {
		return TYPE;
	}

	public static Type<TagAThoughtHandler> getType() {
		return TYPE;
	}

	public static void fire(HasHandlers source, TagDef tagDef) {
		source.fireEvent(new TagAThoughtEvent(tagDef, source));
	}
}
